﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SocialVoting.Helpers
{
    public static class ThemeHelper
    {
        public static IList<SelectListItem> GetSelectedList(HttpCookie selectedTheme)
        {            
            var list = new List<SelectListItem>{new SelectListItem {Text = "Dark", Value = "Dark"},
                            new SelectListItem {Text = "Light", Value = "Light"}};
            if (selectedTheme != null)
            {
                foreach (var selectListItem in list.Where(selectListItem => selectListItem.Value.Equals(selectedTheme.Value)))
                {
                    selectListItem.Selected = true;
                }
            }
            return list;
        }

        public static string GetTheme(HttpCookie theme)
        {
            if (theme == null)
            {
                return "~/Content/Themes/Dark.css";
            }
            else
            {
                return string.Format("~/Content/Themes/{0}.css", theme.Value);
            }
        }
    }
}